package com.smooth.site.sx.pc.offer.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smooth.common.pc.interceptor.PcAccountContext;
import com.smooth.common.site.common.rsp.ReturnResult;
import com.smooth.dao.gen.bean.BizOffer;
import com.smooth.dao.gen.bean.BizStudent;
import com.smooth.site.sx.mag.biz.applyjob.service.BizJobApplayService;
import com.smooth.site.sx.pc.offer.enums.OfferStatus;
import com.smooth.site.sx.pc.offer.req.OfferReq;
import com.smooth.site.sx.pc.offer.service.PcOfferService;
import com.smooth.sys.pc.vo.ListRsp;

@Controller
@RequestMapping(value = "/pc/c")
public class PcStuOfferController {
	@Autowired
	PcOfferService pcOfferService;
	@Autowired
	BizJobApplayService bizJobApplayService;
	
	@RequestMapping(value = { "stu/offer/upd/status" }, method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public ReturnResult stuUpdStatus(@Valid OfferReq offerReq, BindingResult result, HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		BizOffer bizOffer = pcOfferService.statusBizoffer(offerReq.getOfferId(), OfferStatus.getStatus(offerReq.getOfferStatus()));
		returnResult.setData(bizOffer);
		return returnResult;
	}
	
	@RequestMapping(value = { "stu/offer/list" }, method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public ReturnResult list(Integer offerStatus,HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		BizStudent bizStudentSec = (BizStudent) PcAccountContext.getObj(BizStudent.class);
		
		ListRsp<BizOffer> blist = pcOfferService.queryStuBizoffers(bizStudentSec.getId(),offerStatus);
		returnResult.setData(blist);
		
		return returnResult;
	}

}
